-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prototype: create an entity class out of an excel sheet #40
base: master
Are you sure you want to change the base?
Conversation
String fqName = manager.getDefaultNamespace()+"."+dataName; | ||
if (manager.findDataClass(fqName) != null) { | ||
throw new RuntimeException("entity "+fqName+" already exists"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may choose more appropriately how to treat existing classes ... overwrite? delete and forget? ask the user?
switch (cell.getCellType()) { | ||
case NUMERIC: | ||
entity.addField(name, Float.class.getName()); | ||
break; | ||
case STRING: | ||
entity.addField(name, String.class.getName()); | ||
break; | ||
case BOOLEAN: | ||
entity.addField(name, Boolean.class.getName()); | ||
break; | ||
default: | ||
entity.addField(name, String.class.getName()); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle more types?
var name = StringUtils.uncapitalize(names.get(cellNo)); | ||
switch (cell.getCellType()) { | ||
case NUMERIC: | ||
entity.addField(name, Float.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe on the created field we should also apply some magic: e.g define the max length of the string field or whatever
void readToEntity(@TempDir Path dir) throws IOException { | ||
Path path = dir.resolve("customers.xlsx"); | ||
try(InputStream is = TestEntityClassCreator.class.getResourceAsStream("sample.xlsx")) { | ||
Files.copy(is, path, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
|
||
var reader = new EntityClassReader(); | ||
var entity = reader.getEntity(path.toFile().toString()); | ||
assertThat(entity).isNotNull(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
94606cf
to
80a8d0d
Compare
80a8d0d
to
d9937aa
Compare
No description provided.